import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';
import { jwtConstants } from './constances';
import * as entities from './entities/index';
import * as services from './service/index';
import * as controllers from './controller/index';
import { LocalStrategy } from '../stragy/localStragy';
import { JwtStrategy } from '../stragy/jwt.stragy';
import { CommonService } from '../core/base/common.service';
@Module({
  imports: [
    TypeOrmModule.forFeature([...Object.values(entities)]),
    JwtModule.register({
      //生成token的key
      secret: jwtConstants.secret,
      // signOption可以在JwtModule设定
      // 或是在createToken时候设定
      signOptions: {
        //token的有效时长
        expiresIn: '24h',
      },
    }),
    PassportModule,
  ],
  controllers: [...Object.values(controllers)],
  providers: [
    ...Object.values(services),
    LocalStrategy,
    JwtStrategy,
    {
      provide: CommonService,
      useClass: CommonService,
    },
  ],
  exports: [...Object.values(services)],
})
export default class UserModule {}
